<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../../views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>预约信息管理</title>
<head>
    <meta charset="utf-8">
    <title>预约信息管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/css/btable.css" />
    
    <script type="text/javascript" src="/fdoctor-ms/statics/beginnerAdmin/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="/fdoctor-ms/statics/js/jquery-2.1.4.min.js"></script>
    
</head>

<body style=" background-color: gainsboro;">

    <div style="margin:0px; background-color: white;">
        <blockquote class="layui-elem-quote">
        <form class="layui-form" action="">
        	<div class="layui-form-item" align="left" style="margin-left: 0px;margin-top: 10px;">
			  <div class="layui-inline"   >
			    <label class="layui-form-label" > 选择医院：</label>
			    <div class="layui-input-inline" ">			       
			      	<select name="orgId" id="orgId" lay-search>
						<option value="">可输入医院名搜索</option>
						<option value="-1">全部</option>
							<c:forEach items="${hospitalList}" var="hospitalItem">
								<option value="${hospitalItem.id}">${hospitalItem.orgName}</option>
							</c:forEach>
					</select>  
			    </div>
			  	</div>
			  	<div class="layui-inline"  >
				  	<label class="layui-form-label" >时间范围：</label>
				    <div class="layui-input-inline">
				      <input type="date" name="startTime"  class="layui-input"  id="startTime" value="">     
				    </div>
			    </div>
			    <div class="layui-inline" >
			     	<label class="layui-form-label" style="width: 10px;">至</label>
				    <div class="layui-input-inline">
				       <input type="date" name="endTime"  class="layui-input"  id="endTime" value="">   
				    </div>
			    </div>
			    <div class="layui-inline"  >
			    	 <div class="layui-input-inline">
			    	<button class="layui-btn layui-btn-radius" style="width: 150px" id="selectButton" type="button">查询</button>
			    	</div>
			    </div>
			    
			  </div>
			</form>
        </blockquote>
		
        <div id="content" style="width: 100%;height: 500px;"></div>
    </div>

    <script>
    
    	function tableConfig(){
    		layui.config({
                base: '/fdoctor-ms/statics/beginnerAdmin/js/'
            }).use(['btable','layer'], function () {
                var layer = layui.layer;
                
                var btable = layui.btable(),
                    $ = layui.jquery;
                
                //layer.config({
                	//id : Math.ceil(100)	//防止重复弹窗
                //});
                btable.set({
                    elem: '#content',
                    url: '/fdoctor-ms/outpatientOrder/getOrderList',
                    type: 'GET',
                    pageSize: 15,
                    columns: [{
                        fieldName: '预约单id',
                        field: 'id',
                        hidden:	true
                    },{
                        fieldName: '接种人',
                        field: 'personName',
                        colRender : 'typeRenderC'
                    },{
                        fieldName: '接种时间',
                        field: 'orderTime',
                        colRender : 'typeRenderD'
                    },{
                        fieldName: '接种时段',
                        field: 'clinicTime',
                        colRender : 'typeRenderA'
                    },{
                        fieldName: '电话号码',
                        field: 'phoneNumber',
                        colRender : 'typeRenderC'
                    },{
                        fieldName: '家庭住址',
                        field: 'currentAddress',
                        colRender : 'typeRenderC'
                    },{
                        fieldName: '创建时间',
                        field: 'createTime',
                        colRender : 'typeRenderD'
                    },{
                        fieldName: '订单状态',
                        field: 'orderStatus',
                        colRender : 'typeRenderB'
                    }],
                    even: true,
                    //skin: 'row',
                    checkbox: true,
                    field: 'id',
                    paged: true,
                    singleSelect: true,
                    params : packParams(),
                });
                btable.render();

               $(window).on('resize', function (e) {
                    var $that = $(this);
                    $('#content').height($that.height() - 92);
                }).resize();
                
            });
    	}
    	
    	tableConfig();
    
    	//查询按钮声明点击事件，查询逻辑
        $('#selectButton').on('click', function(){
        	tableConfig();
        });
  	  	
        function packParams(){
        	horgId=$("#orgId").val();
        	if(horgId=="-1"){
        		horgId=null
        	}
        	
    		var param = {
    				orgId:horgId,
    				startTime:$("#startTime").val(),
    				endTime:$("#endTime").val()
    		}
    		return param;
    	}
        function typeRenderA(data){
        	if(data == '0'){
        		return '上午';
        	}else if(data == '1'){
        		return '下午';
        	}else{
        		return data;
        	}
        }
		function typeRenderB(data){
        	if(data == '1'){
        		return '已预约';
        	}else if(data == '2'){
        		return '已取消';
        	}else{
        		return data;
        	}
        }
		function typeRenderC(data){
        	if(data == undefined ){
        		return '';
        	}else{
        		return data;
        	}
        }
		function typeRenderD(data){
			var d = new Date(parseInt(data));
			var pp=d.getFullYear();
			  
			if(d.getMonth()<9){
				var dmonth = ("0" + (d.getMonth() + 1)).slice(-2);
			}else{
				var dmonth=d.getMonth() + 1;
			}
			if(d.getDate()<10){
				var dday=("0" + d.getDate()).slice(-2);
			}else{
			var dday=d.getDate();
			}
			d= d.getFullYear() + '-' + dmonth + '-' +dday; 
			return d;
        }
    </script>
</body>
</html>